package com.sykj.zhensiyuan.controller;

import ch.qos.logback.core.pattern.FormatInfo;
import com.sykj.exception.ExceptionControllerAdvice;
import com.sykj.sys.SysRole;
import com.sykj.utils.ResponseResult;
import com.sykj.utils.ResultCode;
import com.sykj.zhensiyuan.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName aa
 * @Description TODO
 * Author JiangPengCheng
 * Date 2020/7/13 21:43
 **/
@CrossOrigin
@RestController
@RequestMapping("/SysRole")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;

    @RequestMapping("/index")
    public ResponseResult index(SysRole sysRole){
        List<SysRole> sysRoleList = sysRoleService.index(sysRole);
        return new ResponseResult(ResultCode.ALL_GET_SUCCESS,sysRoleList);
    }

    @RequestMapping("add")
    public ResponseResult insert(SysRole sysRole){
        sysRoleService.add(sysRole);
        return new ResponseResult(ResultCode.ALL_SVAE_SUCCESS);
    }

    @RequestMapping("update")
    public ResponseResult update(SysRole sysRole){
        sysRoleService.updateById(sysRole);
        return new ResponseResult(ResultCode.ALL_SVAE_SUCCESS);
    }

    @RequestMapping("delete")
    public ResponseResult delete(SysRole sysRole){
        sysRoleService.removeById(sysRole);
        return new ResponseResult(ResultCode.ALL_SVAE_SUCCESS);
    }
}
